Transforms
The transform object allows you to specify clipping, mapping, hit-testing, and viewing information for your shape objects. Like all objects, transform objects have properties that you can examine and edit. When you draw a shape, QuickDraw GX examines the properties of the shape's transform object, modifies the appearance of the shape as indicated by the values of properties
of its transform object (one of which references a list of view port objects), and renders the shape.Figure 3-30 shows the properties of the transform object and gives some sample effects.
Figure 3-30 Transform objects and examples of their properties
The next few sections discuss the clip, mapping, and view port list properties of the transform object.
Clips
The clip property of a transform object allows you to clip a shape--that is, limit the amount of the shape that is drawn to a certain area. As an example, you could set the clip property of the transform object of all of your shapes to limit their drawing area to a certain rectangular area.You are not limited to rectangular clips, however. You can have many different kinds of clips: polygons, paths, glyphs, in some cases even bitmaps!
Figure 3-31 shows two sample shapes modified by their transform clips.
Figure 3-31 Sample shapes clipped by transforms
In the upper half of this figure, a rectangle shape is clipped by a jug-shaped path. In the lower half of this figure, a path shape is clipped by a path that consists of thick, wavy lines. After the shapes are clipped, only those parts of the original shapes that intersect with their clip shape are actually shown.
You can examine or modify the clip property of a transform object using the
GXGetTransformClip
andGXSetTransformClip
functions. Similarly, you can examine and modify the clip of an transform associated with a specified shape using theGXGetShapeClip
andGXSetShapeClip
functions.If you want no clipping to occur, you can specify that the clip shape be a full shape--this is called a full clip (and it is the default).
Mappings
The mapping property of a transform object contains a matrix that QuickDraw GX multiplies against the geometric coordinates of a shape before drawing the shape. With this mapping matrix, you can distort a shape in many ways: scaling, skewing, rotating, adding perspective, and so on. If you want no mapping to occur, you can specify the identity mapping (which is the default).Figure 3-32 shows some examples of the effects you can create using the mapping property of a shape object.
Figure 3-32 Effects of mappings
You can examine and modify the mapping property of a transform
object directly using the functionsGXGetTransformMapping
andGXSetTransformMapping
. Similarly, QuickDraw GX provides the functionsGXGetShapeMapping
andGXSetShapeMapping
for manipulating the mapping property of the transform object associated with a particular shape.QuickDraw GX also provides a number of functions that perform certain calculations on the mapping matrix of a transformation for you. These functions include
GXMoveTransform
,GXMoveTransformTo
,GXScaleTransform
,GXRotateTransform
, andGXSkewTransform
.A similar group of functions--
GXMoveShape
,GXMoveShapeTo
,GXScaleShape
,GXRotateShape
, andGXSkewShape
--applies transformations to the transform object of a specified shape. (Actually, as mentioned in Chapter 2, depending on the value of the shape's map transform attribute, these functions can instead apply their transformation directly to the geometric points stored in the
shape's geometry.)View-Related Objects
The transform object's view port list property contains a list of references to view port objects. A view port object is an object that represents a drawing destination: for example, a Macintosh window. When you draw a shape, QuickDraw GX renders the shape into the view ports referenced by the view port list of the shape's transform object.The properties of a view port object determine its characteristics:
Figure 3-33 shows the properties of a view port object and the relationship between view ports, view groups, and view devices.
- The clip property specifies the viewable area of the view port. For view ports associated with Macintosh windows, the clip property specifies the content area of the window.
- The mapping property specifies a mapping matrix to be applied to shapes drawn to the view port. This mapping matrix can relocate the shapes--when scrolling the contents of a window, for example. The mapping matrix can also perform other transformations on the shapes drawn to a view port. For example, you could scale the contents of a view port to allow users to see the contents of a window at different magnifications.
- The dither property allows you to specify whether shapes drawn to the view port should be dithered. Dithering is a technique of assigning alternating colors to pixels to achieve the illusion of a color that cannot be represented directly.
- The halftone property allows you to specify whether shapes drawn to a view port should be halftoned. Halftoning is a technique of alternating colors of variable intensities in a fixed cell size to represent a variety of colors.
- The parent view port property contains a reference to another view port object that is the parent of this view port in a view port hierarchy. You use view port hierarchies, for example, to scroll the contents of a window or to create different panes in a window that can all be scrolled separately.
- The child view port list property contains a list of view ports that are children of this view port in a view port hierarchy.
- The view group property identifies the view group to which the view port belongs. Examples of view groups are the on screen view group and offscreen view groups. Each view group can contain any number of view ports and view devices. A view device represents a physical location to
render drawings--a monitor, for example, or a block of memory used for offscreen drawing.
Figure 3-33 View groups, view ports, and view devices
View ports, view groups, and view devices are all objects, although they are limited in some ways. For example, you cannot clone view-related objects and you cannot copy view group objects. QuickDraw GX provides some standard functions to manipulate these objects, as well as functions to examine and modify their properties.
The QuickDraw GX view architecture and the different coordinate spaces
of QuickDraw GX are discussed further in Chapter 4, "Using Macintosh Windows." For a complete discussion, see Inside Macintosh: QuickDraw GX Objects.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help